﻿using System;
using System.Collections.Generic;
using SmartClientPlatform.RemoteClientBase;
using System.ComponentModel;

namespace SmartClientPlatform.OMS.CommonLibrary
{
    [Serializable]
    public class OrderDto3 : OrderDto
    {
    }

    [Serializable]
    public class OrderDto2 : OrderDto
    {
    }
    [Serializable]
    public class OrderDto: DtoBase<Order>
    {
        public DateTime? OrderDate
        {
            get
            {
                return GetValue(x => x.OrderDate);
            }
            set
            {
                SetValue(x => x.OrderDate, value);
            }
        }

        public int OrderID
        {
            get
            {
                return GetValue(x => x.OrderID);
            }
            set
            {
                SetValue(x => x.OrderID, value);
            }
        }

        public CustomerDto Customer
        {
            get
            {
                return GetRef(x => x.Customer, () => new CustomerDto());
            }
            set
            {
                SetRef(x => x.Customer, value);
            }
        }


        public IEnumerable<OrderDetailDto> OrderDetails
        {
            get
            {
                IEnumerable<OrderDetailDto> xxx = GetValue(x => x.OrderDetails, () => new OrderDetailDto());
                return xxx;
            }
        }

        /*
        public BindingList<OrderDetailDto> OrderDetails
        {
            get
            {
                IEnumerable<OrderDetailDto> xxx = GetValue(x => x.OrderDetails, () => new OrderDetailDto());
                BindingList<OrderDetailDto> bl = new BindingList<OrderDetailDto>();
                foreach (var y in xxx)
                {
                    bl.Add(y);
                }
                return bl;
                //return xxx;
            }
        }
        */
    }

    [Serializable]
    public class OrderDetailDto : DtoBase<OrderDetail>
    {
        public decimal? Price
        {
            get
            {
                return GetValue(x => x.Price);
            }
            set
            {
                SetValue(x => x.Price, value);
            }
        }

        public int Quantity
        {
            get
            {
                return GetValue(x => x.Quantity);
            }
            set
            {
                SetValue(x => x.Quantity, value);
            }
        }

        public ProductDto Product
        {
            get
            {
                return GetRef(x => x.Product, () => new ProductDto());
            }
            set
            {
                SetRef(x => x.Product, value);
            }
        }

    }

    [Serializable]
    public class ProductDto : DtoBase<Product>
    {
        public string Name
        {
            get
            {
                return GetValue(x => x.Name);
            }
            set
            {
                SetValue(x => x.Name, value);
            }
        }
    }

    [Serializable]
    public class CustomerDto : DtoBase<Customer>
    {
        public string FirstName
        {
            get
            {
                return GetValue(x => x.FirstName);
            }
            set
            {
                SetValue(x => x.FirstName, value);
            }
        }

        public string LastName
        {
            get
            {
                return GetValue(x => x.LastName);
            }
            set
            {
                SetValue(x => x.LastName, value);
            }
        }

    }
}